//
//  LGBallDetailFollowNormalCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/8/25.
//  药球详情--随访记录

#import "LGFollowRecordNormalCell.h"

@interface LGFollowRecordNormalCell()
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UIButton *dateButton;
/**   */
@property (nonatomic , strong)UILabel *statusLabel;
/**   */
@property (nonatomic , strong)UILabel *contentLabel;

@end

@implementation LGFollowRecordNormalCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return  self;
}

-(void)setType:(NSString *)type{
    _type = type;
    self.dateButton.frame = CGRectMake(viewPix(29), viewPix(8), viewPix(150), viewPix(20));
    [self.contentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.contentView).offset(-viewPix(8));
    }];
    if([type isEqualToString:@"top"]){
        self.baseView.layer.cornerRadius = 15;
        [self.baseView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView).offset(viewPix(2));
            make.bottom.equalTo(self.contentView).offset(viewPix(15));
        }];
        self.dateButton.frame = CGRectMake(viewPix(29), viewPix(12), viewPix(150), viewPix(20));
        
    }else if ([type isEqualToString:@"middle"]){
        self.baseView.layer.cornerRadius = 0;
        [self.baseView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView).offset(-viewPix(2));
            make.bottom.equalTo(self.contentView).offset(viewPix(2));
        }];
    }else if ([type isEqualToString:@"bottom"]){
        self.baseView.layer.cornerRadius = 15;
        [self.baseView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView).offset(-viewPix(15));
            make.bottom.equalTo(self.contentView).offset(-viewPix(2));
        }];
        [self.contentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.contentView).offset(-viewPix(12));
        }];
    }else{
        self.baseView.layer.cornerRadius = 15;
        [self.baseView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView).offset(viewPix(2));
            make.bottom.equalTo(self.contentView).offset(-viewPix(2));
        }];
        [self.contentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.contentView).offset(-viewPix(12));
        }];
    }
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    [self.dateButton setTitle:LGNSString(dataDic[@"followup_date"]) forState:UIControlStateNormal];
    self.contentLabel.text = LGNSString(dataDic[@"remarks"]);
    NSString *type = LGNSString(dataDic[@"followup_type"]);
    if([type isEqualToString:@"1"]){
        //电话随访
        self.statusLabel.text = LGNSString(dataDic[@"call_state_name"]);
    }else if([type isEqualToString:@"2"]){
        //短信随访
        self.statusLabel.text = @"已发送";
    }else{
        self.statusLabel.text = @"";
    }
}

#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    self.clipsToBounds = YES;
    self.backgroundColor = [UIColor clearColor];
    self.contentView.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.baseView];
    [self.contentView addSubview:self.dateButton];
    [self.contentView addSubview:self.statusLabel];
    [self.contentView addSubview:self.contentLabel];
    [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(viewPix(2));
        make.bottom.equalTo(self.contentView).offset(viewPix(5));
        make.left.equalTo(self.contentView).offset(viewPix(16));
        make.right.equalTo(self.contentView).offset(-viewPix(16));
    }];
    [self.statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(viewPix(140));
        make.centerY.equalTo(self.dateButton);
    }];
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(viewPix(28));
        make.right.equalTo(self.contentView).offset(-viewPix(28));
        make.top.equalTo(self.dateButton.mas_bottom).offset(viewPix(8));
        make.bottom.equalTo(self.contentView).offset(-viewPix(8));
    }];
}

-(UIView *)baseView{
    if(!_baseView){
        _baseView = [UIView shadowViewWithColor:@"#B3C5D9" offset:CGSizeMake(0, 2) opacity:0.15 radius:0];
        _baseView.backgroundColor = [UIColor whiteColor];
    }
    return _baseView;
}

-(UIButton *)dateButton{
    if(!_dateButton){
        _dateButton = [UIButton buttonWithTitle:@"" titleFont:LGFont(14) textColor:@"#666666" imageName:@"药球患者-时钟"];
        _dateButton.frame = CGRectMake(viewPix(29), viewPix(8), viewPix(150), viewPix(20));
        _dateButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        _dateButton.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
        _dateButton.userInteractionEnabled = NO;
    }
    return _dateButton;
}

-(UILabel *)statusLabel{
    if(!_statusLabel){
        _statusLabel = [UILabel lableWithText:@"" colorString:@"#666666" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _statusLabel;
}

-(UILabel *)contentLabel{
    if(!_contentLabel){
        _contentLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFont(15) textAlignment:NSTextAlignmentLeft lines:0];
    }
    return _contentLabel;
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
